
    e = Sketchup.active_model.selection[0]
    组件定义名=e.definition.name
    组件实例名=e.name
    # e=e.definition
    dictionaries = e.attribute_dictionaries
    动态属性s = e.attribute_dictionaries["dynamic_attributes"]
    动态属性s.each { | key, value |
      puts "key"
      puts key
      puts "value"
      puts value
    }




    e = Sketchup.active_model.selection[0]
    组件定义名=e.definition.name
    组件实例名=e.name
    e=e.definition
    dictionaries = e.attribute_dictionaries
    动态属性s = e.attribute_dictionaries["dynamic_attributes"]
    排除属性arr = ["description", "dialogheight", "dialogwidth",
      "imageurl","itemcode","name","scaletool","summary"
    ]
    xyzarr = ["x", "y", "z",
      "lenx","leny","lenz"
    ]
    动态属性s[:x]=""
    动态属性s[:y]=""
    动态属性s[:z]=""

    其他属性id初始值=6
    动态属性arr=[]
    动态属性s.each { | key, value |
      关键词位置= key=~ /^_/
      if 关键词位置!=nil
        next
      end
      if 排除属性arr.include?(key)
        next
      end

      if xyzarr.include?(key)
        case key
        when "x"
          id=0
        when "y"
          id=1
        when "z"
          id=2
        when "lenx"
          id=3
        when "leny"
          id=4
        when "lenz"
          id=5
        end
      else
        id=其他属性id初始值
        其他属性id初始值=其他属性id初始值+1
      end
      hash=Hash[]

      hash[:id]=id
      hash[:key]=key
      hash[:value]=value
      label="_#{key}_formlabel"
      # puts "#{label} = #{动态属性s[label]}"
      hash[:formlabel]=动态属性s[label]
      formula="_#{key}_formula"
      # puts "#{label} = #{动态属性s[label]}"
      hash[:formula]=动态属性s[formula]
      动态属性arr.push hash
    }
    puts 动态属性arr.to_json



    .根据数组中的对象的某个属性值排序；

	var arr5 = [{id:10},{id:5},{id:6},{id:9},{id:2},{id:3}];
	arr5.sort(function(a,b){
		return a.id - b.id
	})
	console.log(arr5);
	//输出新的排序
	//		{id: 2}
	//		{id: 3}
	//		{id: 5}
	//		{id: 6}
	//		{id: 9}
	//		{id: 10}
————————————————
版权声明：本文为CSDN博主「milijiangjun」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
原文链接：https://blog.csdn.net/milijiangjun/article/details/108144957





    entity1 = entities[1]
    id = entity1.entityID

      # puts 'kk:'
      # puts e.get_attribute "dynamic_attributes", '_y_formula'
      # puts 'kk:'
      # puts e.get_attribute "dynamic_attributes", '_bh_formula'

      # http://cn.voidcc.com/question/p-ggqpvkrd-kh.html
      # 动态组件自定义属性名称前面加_，可以设置其公式
      e.set_attribute 'dynamic_attributes', '_bh_formula', 'box整柜!LenX-LenX'



e = Sketchup.active_model.selection[0]
组件定义名=e.definition.name
组件实例名=e.name
# 是不是definition差别很大！
# e_def=e.definition

# e_def.set_attribute 'dynamic_attributes', 'lenx', 59
kk=e.set_attribute 'dynamic_attributes', '_x_formula', '57+32'
puts "kk"
puts kk
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(e)


# 删除原有的属性，用代码的方式是可以设置属性公式的
e = Sketchup.active_model.selection[0]
组件定义名=e.definition.name
组件实例名=e.name
e_def=e.definition
e_def.set_attribute 'dynamic_attributes', '_x_formula', '100-6'
e_def.set_attribute 'dynamic_attributes', '_x_access', "TEXTBOX"
e_def.set_attribute 'dynamic_attributes', '_x_formulaunits', "CENTIMETERS"
e_def.set_attribute 'dynamic_attributes', '_x_units', "MILLIMETERS"
# e_def.set_attribute 'dynamic_attributes', '_inst__x_formula', '99+3'
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(e)

e = Sketchup.active_model.selection[0]
组件定义名=e.definition.name
组件实例名=e.name
e_def=e.definition
e_def.get_attribute 'dynamic_attributes', '_inst__x_formula'



e = Sketchup.active_model.selection[0]
组件定义名=e.definition.name
组件实例名=e.name
e_def=e.definition
e_def.set_attribute 'dynamic_attributes', '_am_nominal', 8888888/25.4
# e_def.set_attribute 'dynamic_attributes', 'am', 8888888/25.4
# e_def.set_attribute 'dynamic_attributes', '_leny_nominal', 99/25.4
# e_def.set_attribute 'dynamic_attributes', '_leny_formula', 'kk'
# e_def.set_attribute 'dynamic_attributes', '_kk_access', 'TEXTBOX'
# e_def.set_attribute 'dynamic_attributes', '_kk_formlabel', '板件kk'
# e_def.set_attribute 'dynamic_attributes', '_kk_formulaunits', 'CENTIMETERS'
# e_def.set_attribute 'dynamic_attributes', '_kk_label', 'KK'
# e_def.set_attribute 'dynamic_attributes', '_kk_options', '&'
# e_def.set_attribute 'dynamic_attributes', '_kk_units', 'MILLIMETERS'
# e_def.set_attribute 'dynamic_attributes', '_am_formula', '50'
# e_def.set_attribute 'dynamic_attributes', '_bh_formula', '2+8-(5+1)'
# e_def.set_attribute 'dynamic_attributes', 'am', 1/25.4
# e_def.set_attribute 'dynamic_attributes', 'qjk', 18000/25.4
# e_def.set_attribute 'dynamic_attributes', 'bh', 18/25.4
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(e)

e = Sketchup.active_model.selection[0]
组件定义名=e.definition.name
组件实例名=e.name
e_def=e.definition
e_def.set_attribute 'dynamic_attributes', 'am', '10'
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(e)



# sang = Sketchup.active_model.entities[0]
sang = Sketchup.active_model.selection[0]
sang_def = sang.definition
sang_def.set_attribute 'dynamic_attributes', 'am', '19'
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(sang)


sang = Sketchup.active_model.selection[0]
sang_def = sang.definition
sang_def.set_attribute 'dynamic_attributes', '_weight_formula', '1'
dcs.redraw_with_undo(sang)


sang = Sketchup.active_model.selection[0]
sang_def = sang.definition
# sang_def.set_attribute 'dynamic_attributes', 'bh', '188'
sang_def.set_attribute 'dynamic_attributes', '_bh_formula', '1.8'
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(sang)





http://cn.voidcc.com/question/p-ggqpvkrd-kh.html

从谷歌工程师谁创建的动态组件SketchUp和发布此代码对the SketchUcation Forum：

UI.menu("Plugins").add_item('Make Sang Red') {

# Assumes that sang is the 1st entity in model.
sang = Sketchup.active_model.entities[0]

sang = Sketchup.active_model.selection[0]
sang_def = sang.definition

# Override sang's shirt color to red. ("material"
# is a special attribute that requires
# you to set a formula to "take control"
# over the default material the user has painted.)
sang_def.set_attribute 'dynamic_attributes', 'material', 'red'
sang_def.set_attribute 'dynamic_attributes', '_material_formula', '"red"'

# Add a new configurable option to Sang.
# (Any attribute that starts with an underscore
# is a "meta attribute" that describes behavior.)
sang_def.set_attribute 'dynamic_attributes', 'weight', '145'
sang_def.set_attribute 'dynamic_attributes', '_weight_label', 'weight'
sang_def.set_attribute 'dynamic_attributes', '_weight_formlabel', 'My Weight'
sang_def.set_attribute 'dynamic_attributes', '_weight_units', 'STRING'
sang_def.set_attribute 'dynamic_attributes', '_weight_access', 'TEXTBOX'

# Change the description that shows
# up in the configure box with a custom
# formula.
# sang_def.set_attribute 'dynamic_attributes', '_description_formula', '"Sang is now red and weighs " & weight'

# There is a global handle into the plugin that
# allows you to make the same calls that the
# plugin does, like so...
dcs = $dc_observers.get_latest_class
dcs.redraw_with_undo(sang)
}



https://www.cnblogs.com/pengchenggang/p/16313691.html

修改 vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  base: './', // <-- 增加相对路径
})

打包后的 index.html 里面有 script
<script type="module" crossorigin src="./assets/index.3914429b.js"></script>
替换为

<script defer src="./assets/index.3914429b.js"></script>
